<template>
  <view class="wrap">
    <uv-navbar :fixed="false" title="自动回复" autoBack safeAreaInsetTop placeholder :border='false'>
      <template v-slot:left>
        <view class="navEditName nav-left">取消</view>
      </template>
      <template v-slot:right>
        <view class="navEditName nav-right" @click="keyUp">保存</view>
      </template>
    </uv-navbar>
    <view class="input">
      <uv-textarea v-model="body.reply_text" placeholder="请输入" height='600rpx' maxlength='-1' border='none' placeholderStyle='font-size: 28rpx' :textStyle="{fontSize: '28rpx', color: '#2B2B2B'}"></uv-textarea>
    </view>
  </view>
</template>

<script setup>
import { ref, computed } from 'vue';
import { editGroup, getGroup, toast } from '@/common';
import { useOrder } from '@/store';

const body = computed(() => {
  const store = useOrder();
  return uni.$uv.deepClone(store.group);
});

function keyUp(){
  const { id,  reply_text} = body.value;
  if(!body.value.reply_text) return toast('请输入内容');
  const params = {
    id,
    reply_text
  }
  editGroup(params).then(res => {
    toast('修改成功', true);
    getGroup(body.value.id);
    setTimeout(() => {
      uni.navigateBack({
        delta: 1
      });
    }, 1000)
  })
}
</script>

<style lang="scss" scoped>
  .input{
    padding: 30rpx;
    background-color: #fff;
    :deep(.uv-textarea){
      padding: 0;
    }
  }
  .navEditName{
    font-weight: 400;
    font-size: 28rpx;
    &.nav-left{
      color: #737373;
    }
    &.nav-right{
      color: #E43222;
    }
  }
  .status{
    width: 100%;
    height: 20rpx;
    background-color: #F5F5F5;
  }
  .wrap{
    width: 100%;
    min-height: 100vh;
    background-color: #FFFFFF;
  }
</style>